﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        #myDiv .imgBox {
            display: inline-block;
            height: 280px;
            width: 200px;
            font-size: 12px;
            margin: 2px;
            overflow: hidden;
        }

        #myDiv .imgBox img {
            width: 100px;
            height: 100px;
        }

        #myDiv .imgBox .FaceQuality {
            width: 100px;
            height: 100px;
        }
    </style>
    <script src="config.js"></script>
    <script src="jquery-3.3.1.min.js"></script>
    <script src="jquery.lazyload.min.js"></script>
    <script>
        $(function () {
            var serverIP = caijingdaxueip;                                    //要访问的Ip
            var id = decodeURI(window.location.href).split("?id=")[1];        //人档id
            if (id) {
                $("#id").val(id);
                $.get(serverIP + "/acvsInfo?id=" + $("#id").val(), function (data) {
                    loadJSON(JSON.parse(data))
                })
            }

            function formatTime(number, format) {

                var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
                var returnArr = [];

                var date = new Date(number * 1000);
                returnArr.push(date.getFullYear());
                returnArr.push(formatNumber(date.getMonth() + 1));
                returnArr.push(formatNumber(date.getDate()));

                returnArr.push(formatNumber(date.getHours()));
                returnArr.push(formatNumber(date.getMinutes()));
                returnArr.push(formatNumber(date.getSeconds()));

                for (var i in returnArr) {
                    format = format.replace(formateArr[i], returnArr[i]);
                }
                return format;
            }

            //数据转化
            function formatNumber(n) {
                n = n.toString();
                return n[1] ? n : '0' + n
            }

            //生成结果
            function loadJSON(arcs) {
                console.log(arcs);
                for (var i = 0; i < arcs.length; i++) {

                    //else {
                    if(arcs[i].score < 200000){
                        var score = '<div style="background:green;">score:' + arcs[i].score + '</div>';
                    }
                    else {
                        if(arcs[i].score != null) {
                            var score = '<div style="background:yellow;">score:' + arcs[i].score + '</div>';
                        }
                        else {
                            var score = "";
                        }
                    }
                    //var score = (arcs[i].score != null) ? '<div style="background:green;">score:' + arcs[i].score + '</div>' : "";
                    if(arcs[i].detectFacev2 != null){
                        if(arcs[i].detectFacev2 == 1){
                            var detectFacev2 = '<div style="background:green;">detectFacev2:' + arcs[i].detectFacev2 + '</div>';
                        }
                        else {
                            var detectFacev2 = '<div style="background:#888\t;">detectFacev2:' + arcs[i].detectFacev2 + '</div>';
                        }
                    }
                    else {
                        var detectFacev2 = "";
                    }
                    var scorein = (arcs[i].score_in != null) ? '<div style="background:yellow;">score_in:' + arcs[i].score_in + '</div>' : "";
                    var scoreout = (arcs[i].score_out != null) ? '<div style="background:yellow;">score_out:' + arcs[i].score_out + '</div>' : "";

                    if(arcs[i].x != null&&Math.abs(arcs[i].x) <= 40&&Math.abs(arcs[i].y) <= 40&&Math.abs(arcs[i].z) <= 40){
                        var x = '<div style="background:green;">x:' + Number(arcs[i].x).toFixed(2) + '</div>';
                        var y = '<div style="background:green;">y:' + Number(arcs[i].y).toFixed(2) + '</div>';
                        var z = '<div style="background:green;">z:' + Number(arcs[i].z).toFixed(2) + '</div>';
                    }
                    else {
                        var x = (arcs[i].x != null) ? '<div>x:' + Number(arcs[i].x).toFixed(2) + '</div>' : "";
                        var y = (arcs[i].y != null) ? '<div>y:' + Number(arcs[i].y).toFixed(2) + '</div>' : "";
                        var z = (arcs[i].z != null) ? '<div>z:' + Number(arcs[i].z).toFixed(2) + '</div>' : "";
                    }
                    var blur = (arcs[i].blur != null) ? '<div>blur:' + Number(arcs[i].blur) + '</div>' : "";
                    var detectFace = (arcs[i].detectFace != null) ? '<div title="' + arcs[i].detectFace + '">detectFace:' + arcs[i].detectFace + '</div>' : "";
                    var timeta = (arcs[i].timestamp != null) ? formatTime(arcs[i].timestamp, 'Y/M/D h:m:s') : "";
                    //var time = formatTime(arcs[i].timestamp, 'Y/M/D h:m:s');
                    var id = (arcs[i].id != null) ? '<div>' + arcs[i].id + '</div>' : "";
                    var faceid = (arcs[i].face_id != null) ? '<div>' + arcs[i].face_id + '</div>' : "";
                    var acvsid = (arcs[i].acvsfllow != null) ? '<div>' + arcs[i].acvsfllow + '</div>' : "";
                    var name = (arcs[i].name != null) ? '<div>name:' + arcs[i].name + '</div>' : "";
                    var similarity = (arcs[i].similarity != null) ? '<div>similarity:' + arcs[i].similarity + '</div>' : "";
                    var card_id = (arcs[i].card_id != null) ? '<div>card_id:' + arcs[i].card_id + '</div>' : "";
                    var similarity_high = (arcs[i].similarity_high != null) ? '<div>similarity_high:' + arcs[i].similarity_high + '</div>' : "";
                    var similarity_low = (arcs[i].similarity_low != null) ? '<div>similarity_low:' + arcs[i].similarity_low + '</div>' : "";
                    var similarity_average = (arcs[i].similarity_average != null) ? '<div>similarity_average:' + arcs[i].similarity_average + '</div>' : "";
                    var count = (arcs[i].count != null) ? '<div>count:' + arcs[i].count + '</div>' : "";
                    var level = (arcs[i].level != null) ? '<div>level:' + arcs[i].level + '</div>' : "";



                    if(arcs[i].detectCount != null&&arcs[i].detectCount > 1){
                        var faceCount = (arcs[i].detectCount != null) ? '<div style="background:red;">detectCount:' + arcs[i].detectCount + '</div>' : "";
                    }
                    else {
                        var faceCount = (arcs[i].detectCount != null) ? '<div>detectCount:' + arcs[i].detectCount + '</div>' : "";
                    }

                    var url = "caijingacvs.html?id=" + arcs[i].acvsfllow;
                    var arr = Object.keys(arcs[i]);

                    if (arr.length == 0) {
                        var $item = $('<br>' + '<hr>' + '<br>' + '<br>' + '<br>' + '<hr>');
                    }

                    else {
                        var $item = $('<div class="imgBox">' +
                            '<a href="' + url +' " target="_blank">   <img src="' + arcs[i]["face_image_uri"] + '" alt="' + arcs[i].id + '"> </a>' +
                            score +
                            scorein +
                            scoreout +
                                similarity_low +
                                similarity_average +
                                count +
                                level +
                            x +
                            y +
                            z +
                            blur +
                            timeta +
                            detectFace +
                                faceCount +
                            name +
                            similarity_high +
                            similarity +
                            card_id +
                            acvsid +
                            detectFacev2 +
                            //'<div title="'+ arcs[i].emoticons +'">'+ arcs[i].emoticons+'</div>' +
                            //'<div>quality:'+ (arcs[i].quality === undefined?'':Number(arcs[i].quality).toFixed(2))+'</div>' +
                            //'<div title="'+ Number(arcs[i].FaceQuality).toFixed(2) +'">FaceQuality:'+ (arcs[i].FaceQuality === undefined?'':Number(arcs[i].FaceQuality).toFixed(2))+'</div>' +
                            id +
                            faceid +

                            '</div>')
                    }
                    $('#myDiv').append($item)
                }
                $("img").lazyload();

            }
        })
    </script>
</head>
<body style='background:#777'>
<input id="id" type="hidden" value=""/>
<div id="myDiv"></div>
</body>
</html>